package shun.demo;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import shun.demo.remote.touch.EventHub;
import shun.demo.utils.Singleton;

import java.util.Observable;
import java.util.Observer;

/**
 * Created by chen on 14-4-29.
 */
public class BaseActivity extends ActionBarActivity implements Observer {

    private EventHub mEventHub;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mEventHub = Singleton.get(EventHub.class);
    }

    @Override
    protected void onResume() {
        super.onResume();
        mEventHub.addObserver(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
        mEventHub.deleteObserver(this);
    }

    @Override
    public void update(Observable observable, Object data) {
        dispatchTouchEvent((android.view.MotionEvent) data);
    }
}
